/**
* 弹窗组件，使用： this.$store.dispatch('setModal', {visible: true, modalId: 'groupClearanceModal',groupId:''}); 注意this指向的上下文环境，有时候是写self或其它
*/
<template>
  <transition name="slide-fade">
    <div v-if="modal.visible && modal.modalId=='groupClearanceModal'" class="modal" id="groupClearanceModal" tabindex="-1" @click.stop.prevent="modalHide">
      <div class="modal-dialog" @click.stop.prevent>
        <div class="modal-content">
          <img src="~assets/images/tankuang-m@2x.png" class="img-responsive">
          <img src="~assets/images/close@2x.png" data-dismiss="modal" class="img-close" @click.stop.prevent="modalHide">
          <div class="oxhead">
            <img src="http://dl.app.gtja.com/nrng/shareimages/oxhead/niuwenhao.png">
          </div>
          <div class="wrapper">
            <h4>大王你确认要<span>清仓</span>吗？</h4>
            <p>小的提醒您一旦清仓这个组合的持仓就会全部卖出哦~</p>
            <button type="button" class="btn btn-lg btn-agree" data-group-id="modal.groupId" @click="clearance">朕确定</button>
            <button type="button" class="btn btn-lg btn-reject" @click.stop.prevent="modalHide">算了</button>
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
  import BaseModal from 'components/modal/BaseModal'
  import RemoteDAO from 'common/remoteDAO'
  import LocalDAO from 'common/localDAO'

  export default {
    data () {
      return {}
    },
    extends:BaseModal,
    methods:{
      clearance(){
        var self = this;
        var userCode = LocalDAO.getUserCode();
        var groupId = self.modal.groupId;
        RemoteDAO.callJCL11158(userCode, "2", "8", "8", groupId, function (response) {
          if (response.error == "0") {
            if (response.data.body.status == 0) {
              self.modalHide();
              self.$store.dispatch('setTip',{text:"提交成功，请去委/撤中查看委托状态"});
            } else {
              self.$store.dispatch('setTip',{text:response.data.body.describe});
            }
          } else {
            self.$store.dispatch('setTip',{text:response.data});
          }
        });
      }
    }
  }
</script>

<style scoped>
  .slide-fade-enter-active,.slide-fade-leave-active{
    transition: all 0.3s ease;
  }
  .slide-fade-enter, .slide-fade-leave-active {
    transform: translate(0,-25%);
    opacity: 0;
  }
</style>
